package map_and_set;

import java.util.HashSet;

public class OldKeyBoard {
    public void oldKeyboard(String s1,String s2){
        // 因为输出要求全是大写 所以一开始就将这些都换成大写
        s1 = s1.toUpperCase();
        s2 = s2.toUpperCase();
        // setOut 存放实际输出的字母
        HashSet<Character> setOut = new HashSet<>();
        for(int i = 0; i < s2.length();i++){
            setOut.add(s2.charAt(i));
        }
        // setBroken 存放坏键盘的字母
        HashSet<Character> setBroken = new HashSet<>();
        for(int i = 0;i < s1.length();i++){
            char ch = s1.charAt(i);
            if(!setOut.contains(ch) && !setBroken.contains(ch)){
                setBroken.add(ch);
                System.out.print(ch);
            }
        }
    }
}
